<?php
class redbagController extends baseController
{
	public function __construct()
	{
		parent::__construct();
		$this->visitpath = config('URL_HTTP_PROTOCOL') . $_SERVER['HTTP_HOST'] . "/upload/collectibles/";
		$this->filepath = ROOT_PATH . "upload/collectibles";
	}

	public function send(){
		$wx = new WxApi();

		if(!isset($_GET['code'])){
			header("location:https://open.weixin.qq.com/connect/oauth2/authorize?appid=".WxApi::appId."&redirect_uri=http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."&response_type=code&scope=snsapi_base&state=1#wechat_redirect");
		}
		else{
			$CODE = $_GET['code'];
			$Info = $wx->wxOauthAccessToken($CODE);
			//print_r($Info);
			$openId = $Info['openid'];

		}

		$signPackage = $wx->wxJsapiPackage();
		$this->signPackage=$signPackage;
		$this->display();
	}
}